Option Strict On

Imports System.Data.SqlClient
Imports System.Configuration



''' <summary>
''' Base Business Class to Inherit
''' </summary>
''' <remarks></remarks>
Public MustInherit Class BusinessBase
    Inherits DataFormat

    Public Shared ReadOnly Property ConnectionString() As String
        Get
            Return ConfigurationManager.ConnectionStrings(0).ConnectionString
            '"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\web\DotTag\TagWeb\App_Data\Database.mdf;Integrated Security=True;User Instance=True"
            'ConfigurationManager.ConnectionStrings(0).ConnectionString
        End Get
    End Property

    ''' <summary>
    ''' Executes query and returns a single object as the result.
    ''' </summary>
    ''' <param name="commandText">The command text.</param>
    ''' <param name="commandParameters">The command parameters.</param>
    ''' <returns></returns>
    Public Shared Function ExecuteScalar(ByVal commandText As String, _
                                          ByVal ParamArray commandParameters() As SqlParameter) As Object
        Return SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, commandText, commandParameters)
    End Function

    ''' <summary>
    ''' Executes the querty and returns a datareader
    ''' </summary>
    ''' <param name="commandText">The command text.</param>
    ''' <param name="commandParameters">The command parameters.</param>
    ''' <returns></returns>
    Public Shared Function ExecuteReader(ByVal commandText As String, _
                                          ByVal ParamArray commandParameters() As SqlParameter) As SqlDataReader
        Return SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, commandText, commandParameters)
    End Function


    ''' <summary>
    ''' Executes the query and returns a dataset.
    ''' </summary>
    ''' <param name="commandText">The command text.</param>
    ''' <param name="commandParameters">The command parameters.</param>
    ''' <returns></returns>
    Public Shared Function ExecuteDataset(ByVal commandText As String, _
                                           ByVal ParamArray commandParameters() As SqlParameter) As DataSet
        Return SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, commandText, commandParameters)
    End Function

    Public Shared Function ExecuteDatasetSP(ByVal commandText As String, _
                                             ByVal ParamArray commandParameters() As SqlParameter) As DataSet
        Return _
            SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, commandText, commandParameters)
    End Function

    ''' <summary>
    ''' Executes the a query and returns the number of rows changed
    ''' </summary>
    ''' <param name="commandText">The command text.</param>
    ''' <param name="commandParameters">The command parameters.</param>
    ''' <returns></returns>
    Public Shared Function ExecuteNonQuery(ByVal commandText As String, _
                                            ByVal ParamArray commandParameters() As SqlParameter) As Integer
        Return SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText, commandParameters)
    End Function

    Public Shared Function StripHTML(ByVal input As String) As String
        Return DataFormat.StripHTML(input)
    End Function
End Class
